#include<iostream>


class Bitmap{};
class Class
{
    public:

        /*做法1：如果this->bm 一开始异常，这里则会报错，不是最佳处理方案*/
        Class& operator= (const Class &src)
        {
            if (this == &src)//要处理好自我赋值的情况
            {
                return *this;
            }
            delete this->bm;

            this->bm = src.bm;

            return *this;
        };
        /*做法2：解决this->bm一开始异常的问题*/
        Class& operator= (const Class &src)
        {
            Bitmap *pori = bm;//保存原先
            this->bm = new Bitmap (*src.bm);//开辟新地址
            delete pori;//删除原先
            return *this;//返回新地址
        };

    private:
    Bitmap *bm;
    
};


int main(int argc, char const *argv[])
{
    /* code */
    return 0;
}
